package com.aft.terra.common.utils;

import java.util.Date;
import java.util.Random;

public class CodeUtil {

	public static String getCode() {
		Date date = new Date();
		String time = String.valueOf(date.getTime());
		return time.substring(9, time.length());
	}

	public static String getRandomCode(int length) {
		char[] c = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
		int len = c.length - 1;
		Random r = new Random();
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < length; i++) {
			int number = r.nextInt(len);
			sb.append(c[number]);
		}
		return sb.toString();
	}
	
	public static int getRandom() {
		int min = 0;
		int max = 1000000;
		int num = (int) (Math.random() * (max - min)) + min;
		return num;
	}
	
}
